<template>
    <view class="container">
        <form @submit="bindSave">
            <view class="tui-form">
                <view class="tui-form">
                    <view class="tui-view-input">
                        <block v-for="(item, index) in goodsDetail.equation" :key="index">
                            <tui-list-cell :hover="false" padding="0">
                                <view class="tui-line-cell">
                                    <view class="tui-title">{{ goodsDetail.equation_remark[index] }}</view>
                                    <input v-model="form[item]" placeholder-class="tui-phcolor" class="tui-input" name="name" :placeholder="'请输入' + goodsDetail.equation_remark[index]" type="text" />
                                </view>
                            </tui-list-cell>
                        </block>
                    </view>
                </view>
                <view class="tui-btn-box">
                    <tui-button formType="submit" type="danger" height="88rpx" shape="circle">计算</tui-button>
                </view>
            </view>
        </form>
        <view style="text-align: center; margin-top: 22px; padding: 4px 0; background: #8fde47">得出结果</view>
        <view style="text-align: center; color: red; font-size: 24px; margin-top: 8px">{{ num }}</view>
    </view>
</template>

<script>
export default {
    data() {
        return {
            id: 0,
            goodsDetail: {},
            form: {},
            num: 0
        };
    },
    onLoad: function (e) {
        let _this = this;
        _this.id = e.id;
        _this.getGoodsDetailInfo(e.id);
    },
    onShow() {},
    methods: {
        getGoodsDetailInfo: function (goodsId) {
            const _this = this;
            _this.$request
                .get('goods.detail', {
                    id: goodsId
                })
                .then(res => {
                    if (res.errno == 0) {
                        _this.goodsDetail = res.data;
                    }
                });
        },
        bindSave: function (e) {
            var _this = this;
            _this.form.id = _this.id;
            _this.$request.post('goods.number', _this.form).then(res => {
                if (res.errno == 0) {
                    _this.num=res.data;
                    return;
                } else {
                    //console.log(res.errno);
                    uni.showModal({
                        title: '提示',
                        content: res.msg,
                        showCancel: false,
                        //是否显示取消按钮
                        success: function (res) {
                            if (res.cancel) {
                                //点击取消,默认隐藏弹框
                            } else {
                                uni.reLaunch({
                                    url: '/pagesA/my/admintechnical/index'
                                });
                            }
                        }
                    });
                }
            });
        }
    }
};
</script>

<style lang="scss" scoped>
.tui-list-cell {
    width: 100%;
    color: $uni-text-color;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24rpx 60rpx 24rpx 30rpx;
    box-sizing: border-box;
    font-size: 30rpx;
}

.tui-avatar {
    width: 130rpx;
    height: 130rpx;
    display: block;
}

.uni-list {
    width: 100%;
    padding-top: 15rpx;
    padding-bottom: 20rpx;
    padding-left: 20rpx;
    padding-right: 20rpx;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}

.ptypebut {
    width: 40%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    padding-top: 15rpx;
    padding-bottom: 15rpx;
    margin-bottom: 10rpx;
}

.checkboxbox {
    padding: 20rpx;
}

.container {
    backgroundcolor: #fff;
    padding-bottom: 80rpx;

    .tui-page-title {
        width: 100%;
        font-size: 48rpx;
        font-weight: bold;
        color: $uni-text-color;
        line-height: 42rpx;
        padding: 110rpx 40rpx 40rpx 40rpx;
        box-sizing: border-box;
    }

    .tui-form {
        .tui-view-input {
            width: 100%;
            box-sizing: border-box;
            padding: 0 0rpx;

            .tui-cell-input {
                width: 100%;
                display: flex;
                align-items: center;
                padding-top: 48rpx;
                padding-bottom: $uni-spacing-col-base;

                input {
                    flex: 1;
                    padding-left: $uni-spacing-row-base;
                }

                .tui-icon-close {
                    margin-left: auto;
                }

                .tui-btn-send {
                    width: 156rpx;
                    text-align: right;
                    flex-shrink: 0;
                    font-size: $uni-font-size-base;
                    color: $uni-color-primary;
                }

                .tui-gray {
                    color: $uni-text-color-placeholder;
                }

                .tui-textarea {
                    width: 100%;
                    height: 300rpx;
                    font-size: 28rpx;
                    padding: 20rpx 30rpx;
                    box-sizing: border-box;
                    background-color: #fff;
                }
            }
        }

        .tui-cell-text {
            width: 100%;
            padding: 40rpx $uni-spacing-row-lg;
            box-sizing: border-box;
            font-size: $uni-font-size-sm;
            color: $uni-text-color-grey;
            display: flex;
            align-items: center;

            .tui-color-primary {
                color: $uni-color-primary;
                padding-left: $uni-spacing-row-sm;
            }
        }

        .tui-btn-box {
            width: 100%;
            padding: 0 $uni-spacing-row-lg;
            box-sizing: border-box;
            margin-top: 20rpx;
        }
    }
}
.tui-list-cell {
    width: 100%;
    color: $uni-text-color;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24rpx 60rpx 24rpx 30rpx;
    box-sizing: border-box;
    font-size: 30rpx;
}
.tui-line-cell {
    width: 100%;
    padding: 24rpx 30rpx;
    box-sizing: border-box;
    display: flex;
    align-items: center;
}
.tui-title {
    width: 180rpx;
    font-size: 28rpx;
    flex-shrink: 0;
}

.tui-title-city-text {
    width: 180rpx;
    height: 40rpx;
    display: block;
    line-height: 46rpx;
}
.tui-input {
    width: 500rpx;
}

.tui-avatar {
    width: 130rpx;
    height: 130rpx;
    display: block;
}

.uni-list {
    width: 100%;
    padding-top: 15rpx;
    padding-bottom: 20rpx;
    padding-left: 20rpx;
    padding-right: 20rpx;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}

.ptypebut {
    width: 40%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    padding-top: 15rpx;
    padding-bottom: 15rpx;
    margin-bottom: 10rpx;
}

.checkboxbox {
    padding: 20rpx;
}

.container {
    backgroundcolor: #fff;
    padding-bottom: 80rpx;

    .tui-page-title {
        width: 100%;
        font-size: 48rpx;
        font-weight: bold;
        color: $uni-text-color;
        line-height: 42rpx;
        padding: 110rpx 40rpx 40rpx 40rpx;
        box-sizing: border-box;
    }

    .tui-form {
        .tui-view-input {
            width: 100%;
            box-sizing: border-box;
            padding: 0 0rpx;

            .tui-cell-input {
                width: 100%;
                display: flex;
                align-items: center;
                padding-top: 48rpx;
                padding-bottom: $uni-spacing-col-base;

                input {
                    flex: 1;
                    padding-left: $uni-spacing-row-base;
                }

                .tui-icon-close {
                    margin-left: auto;
                }

                .tui-btn-send {
                    width: 156rpx;
                    text-align: right;
                    flex-shrink: 0;
                    font-size: $uni-font-size-base;
                    color: $uni-color-primary;
                }

                .tui-gray {
                    color: $uni-text-color-placeholder;
                }

                .tui-textarea {
                    width: 100%;
                    height: 300rpx;
                    font-size: 28rpx;
                    padding: 20rpx 30rpx;
                    box-sizing: border-box;
                    background-color: #fff;
                }
            }
        }

        .tui-cell-text {
            width: 100%;
            padding: 40rpx $uni-spacing-row-lg;
            box-sizing: border-box;
            font-size: $uni-font-size-sm;
            color: $uni-text-color-grey;
            display: flex;
            align-items: center;

            .tui-color-primary {
                color: $uni-color-primary;
                padding-left: $uni-spacing-row-sm;
            }
        }

        .tui-btn-box {
            width: 100%;
            padding: 0 $uni-spacing-row-lg;
            box-sizing: border-box;
            margin-top: 20rpx;
        }
    }
}
</style>
